package com.zw.healthy.controller;


import com.zw.commons.log.annotation.Log;
import com.zw.commons.log.enums.BusinessType;
import com.zw.healthy.service.HealthReportService;
import com.zw.object.healthy.HealthReport;
import com.zw.object.result.Result;
import com.zw.object.vo.HealthyReportVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.security.Principal;

/**
 * <p>
 * 二码一报告表 前端控制器
 * </p>
 *
 * @author zw
 * @since 2023-03-16
 */
@Api(tags = "报告信息")
@RestController
@RequestMapping("/healthy/health-report")
public class HealthReportController {

    @Autowired
    private HealthReportService healthReportService;

    @GetMapping("/check")
    @Log(title = "验证信息是否上限",businessType = BusinessType.SELECT)
    @ApiOperation("验证信息是否上限")
    public Result check(HttpServletRequest request){
        return healthReportService.checkReportToday(request);
    }

    @ApiOperation("获取全部报告信息")
    @Log(title = "获取全部报告信息",businessType = BusinessType.SELECT)
    @PostMapping("/list")
    public Result list(@Validated @RequestBody HealthyReportVo vo,HttpServletRequest request){
        return healthReportService.list(vo,request);
    }

    @PostMapping("/save")
    @Log(title = "二码一报告",businessType = BusinessType.INSERT)
    @ApiOperation("二码一报告")
    public Result save(@RequestParam("file1") MultipartFile file1,
                       @RequestParam("file2") MultipartFile file2,
                       @RequestParam("file3") MultipartFile file3,
                       @RequestParam("type") Integer type,
                       HttpServletRequest request) throws Exception {
        return healthReportService.save(file1,file2,file3,type,request);
    }


}

